<?php

class Zendhlt_Form_Element_OpensHours extends Zend_Form_Element_Xhtml {
	
    public $helper = "opensHoursElement";
    protected $monday = null;
    protected $tuesday = null;
    protected $wednesday = null;
    protected $thursday = null;
    protected $friday = null;
    protected $saturday = null;
    protected $sunday = null;

    function setMonday($num) {
        $this->monday = $num;
        return $this;
    }

    function setTuesday($num) {
        $this->tuesday = $num;
        return $this;
    }

    function setWednesday($num) {
        $this->wednesday = $num;
        return $this;
    }
    
	function setThursday($num) {
        $this->thursday = $num;
        return $this;
    }

    function setFriday($num) {
        $this->friday = $num;
        return $this;
    }

    function setSaturday($num) {
        $this->saturday = $num;
        return $this;
    }

    function setSunday($num) {
        $this->sunday = $num;
        return $this;
    }

    public function setValue($value) {
        if (is_array($value)) {
        	foreach ($value as $valDay) {
        		switch ($valDay['day']) {
        			case 'mo':
        				$this->setMonday($valDay);
        				break;
        			
        			case 'tu':
        				$this->setTuesday($valDay);
        				break;
        				
        			case 'we':
        				$this->setWednesday($valDay);
        				break;
        			
        			case 'th':
        				$this->setThursday($valDay);
        				break;
        				
        			case 'fr':
        				$this->setFriday($valDay);
        				break;
        			
        			case 'sa':
        				$this->setSaturday($valDay);
        				break;
        			
        			case 'su':
        				$this->setSunday($valDay);
        				break;
        		}
        	}
        }
    }

    public function getValue() {
        $result = array('mo' => $this->monday, 'tu' => $this->tuesday, 'we' => $this->wednesday, 'th' => $this->thursday,
        				'fr' => $this->friday, 'sa' => $this->saturday, 'su' => $this->sunday);
        return $result;
	}
}